home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / C++ / Applications / SeeMovieRun 2.0 / Source / CQTApp.cp < prev    next >
Encoding:
Text File  |  1995-08-02  |  5.9 KB  |  248 lines  |  [TEXT/KAHL]

  1. /******************************************************************************
  2.  CQTApp.cp
  3.  
  4.                 My Application Class
  5.     
  6.     Copyright © 1995 Gregory Bonk, NewMedia Inc. All rights reserved.
  7.  
  8.     Generated by Visual Architect™ 5:28 PM Tue, Aug 1, 1995
  9.     Portions Copyright © 1992 Joe Zobkiw.  All rights reserved.
  10.     Portions Copyright © 1995 Symantec Corporation.  All rights reserved.
  11.  ******************************************************************************/
  12.  
  13. #include "CQTApp.h"
  14.  
  15. #include <CDialog.h>
  16. #include <TCLForceReferences.h>
  17. #include "CQTDoc.h"
  18. #include "CAboutBox.h"
  19.  
  20. #include <Movies.h>
  21. #include "CEBSwitchboard.h"
  22. #include "CEBCollaborator.h"
  23. #include "QuickTime Utilities.h"
  24.  
  25. long            gQuickTimeVersion;
  26. CEBCollaborator    *gEBCollaborator;
  27.  
  28.  
  29. extern  long            gQuickTimeVersion;
  30. extern  CEBCollaborator    *gEBCollaborator;
  31.  
  32.  
  33. TCL_DEFINE_CLASS_M1(CQTApp, x_CQTApp);
  34.  
  35. /**** C O N S T R U C T I O N / D E S T R U C T I O N   M E T H O D S ****/
  36.  
  37. CQTApp::CQTApp()
  38. {
  39.     TCL_END_CONSTRUCTOR
  40. }
  41.  
  42.  
  43. CQTApp::~CQTApp()
  44. {
  45.     TCL_START_DESTRUCTOR
  46. }
  47.  
  48.  
  49. /******************************************************************************
  50.  ICQTApp
  51.  
  52.     Initialize an Application.Your initialization method should
  53.     at least call the inherited method. If your application class
  54.     defines its own instance variables or global variables, this
  55.     is a good place to initialize them.
  56.  ******************************************************************************/
  57. void    CQTApp::ICQTApp()
  58. {
  59.     OSErr err = noErr;
  60.  
  61.     Ix_CQTApp(4, 24000L, 20480L, 2048L);
  62.     
  63.     if (QuickTimeIsInstalled(&gQuickTimeVersion))
  64.     {
  65.         FailOSErr(EnterMovies());
  66.     }
  67.     else 
  68.     {
  69.         gQuickTimeVersion = 0;
  70.         FailOSErr(gestaltUndefSelectorErr);
  71.     }
  72.     
  73.     gEBCollaborator = new CEBCollaborator();
  74.     gEBCollaborator->IEBCollaborator();        
  75. }
  76.  
  77.  
  78. /******************************************************************************
  79.  ForceClassReferences    {OVERRIDE}
  80.  
  81.  ******************************************************************************/
  82. void CQTApp::ForceClassReferences(void)
  83. {
  84.     inherited::ForceClassReferences();
  85. }
  86.  
  87. /******************************************************************************
  88.  MakeSwitchboard
  89.  
  90.      Create application's switchboard. We use a special "Event Broadcasting"
  91.      Switchboard that will use our gEBCollaborator instance to broadcast events
  92.      to any available Movie Controllers before handling them itself. 
  93.      
  94.      This is how Movie Controllers get thier events.
  95. ******************************************************************************/
  96. void CQTApp::MakeSwitchboard(void)
  97. {
  98.     itsSwitchboard = new CEBSwitchboard();
  99.     itsSwitchboard->InitAppleEvents();
  100. }
  101.  
  102. /******************************************************************************
  103.  SetUpFileParameters
  104.  
  105.     In this routine, you specify the kinds of files your
  106.     application opens.
  107.  ******************************************************************************/
  108. void CQTApp::SetUpFileParameters(void)
  109. {
  110.     inherited::SetUpFileParameters();    /* Be sure to call the default method */
  111.  
  112.     sfNumTypes = 1;
  113.     sfFileTypes[0] = kFileType1;
  114. }
  115.  
  116. /**** C O M M A N D   M E T H O D S ****/
  117.  
  118.  
  119. /******************************************************************************
  120.  DoCommand    {OVERRIDE}
  121.  
  122.     Handle application commands
  123.  ******************************************************************************/
  124. void CQTApp::DoCommand(long theCommand)
  125. {
  126.     FSSpec    spec;
  127.  
  128.     switch (theCommand)
  129.     {
  130.     case cmdAbout:
  131.         DoCmdAbout();
  132.         break;
  133.     case cmdOpen:
  134.         if (GetMovieFileFSSpec(&spec))
  135.             OpenQTDocument(&spec);
  136.         break;
  137.     default:
  138.         inherited::DoCommand(theCommand);
  139.         break;
  140.     }
  141. }
  142.  
  143.  
  144. /******************************************************************************
  145.  CreateDocument
  146.  
  147.     The user chose New from the File menu.
  148.     In this method, you need to create a document and send it
  149.     a NewFile() message.
  150.  ******************************************************************************/
  151. void CQTApp::CreateDocument()
  152. {
  153.     CQTDoc    *theDocument = NULL;
  154.     
  155.     TRY
  156.     {
  157.         theDocument = new CQTDoc();
  158.         theDocument->ICQTDoc();
  159.         theDocument->NewFile();
  160.     }
  161.     CATCH
  162.     {
  163.         TCLForgetObject(theDocument);
  164.     }
  165.     ENDTRY
  166. }
  167.  
  168. /******************************************************************************
  169.  OpenDocument
  170.  
  171.     Converts the TCL’s SFReply into an FSSpec and then calls OpenQTDocument to
  172.     open the movie document. This is only used when a movie is double-clicked
  173.     from the Finder or an odoc AppleEvent is sent.
  174.  ******************************************************************************/
  175. void CQTApp::OpenDocument(SFReply *macReply)
  176. {
  177.     FSSpec    spec;
  178.     
  179.     FailOSErr(FSMakeFSSpec(macReply->vRefNum, 0L, macReply->fName, &spec));
  180.     this->OpenQTDocument(&spec);
  181. }
  182.  
  183. /******************************************************************************
  184.  OpenQTDocument
  185.  
  186.     Open a document using the FSSpec provided. In this case, it will be spec to a
  187.     Movie document.
  188.  ******************************************************************************/
  189. void CQTApp::OpenQTDocument(FSSpec *spec)
  190. {
  191.     CQTDoc    *theDocument = NULL;
  192.  
  193.     TRY
  194.     {    
  195.         theDocument = new CQTDoc();
  196.         theDocument->ICQTDoc();
  197.         theDocument->OpenQTFile(spec);
  198.     }
  199.     CATCH
  200.     {
  201.         TCLForgetObject(theDocument);
  202.     }
  203.     ENDTRY
  204. }
  205.  
  206.  
  207. /******************************************************************************
  208.  DoCmdAbout
  209.  
  210.     Show the About Box
  211.  ******************************************************************************/
  212. void CQTApp::DoCmdAbout()
  213. {
  214.     CAboutBox        *dialog;
  215.     
  216.     dialog = new CAboutBox();
  217.  
  218.     TRY
  219.     {
  220.         dialog->ICAboutBox(this);
  221.         dialog->BeginDialog();
  222.         dialog->DoModalDialog(cmdNull);
  223.         
  224.         TCLForgetObject(dialog);
  225.     }
  226.     CATCH
  227.         TCLForgetObject(dialog);
  228.     ENDTRY
  229.  
  230. }
  231.  
  232.  
  233. /******************************************************************************
  234.  Exit
  235.  
  236.     Chances are you won't need this method.
  237.     This is the last chance your application gets to clean up
  238.     things like temporary files before terminating.
  239.  ******************************************************************************/
  240. void CQTApp::Exit()
  241. {
  242.     if (gQuickTimeVersion != 0)
  243.         ExitMovies();                    // tell QuickTime we are through
  244.     
  245.     if (gEBCollaborator != NULL)
  246.         TCLForgetObject(gEBCollaborator);        // nuke our global CEBCollaborator
  247. }
  248.